package com.night.card.controller;

import com.github.pagehelper.PageInfo;
import com.night.card.service.interfs.CardInMachineService;
import com.night.card.vo.CardDataVo;
import com.night.common.entity.ResultVo;
import com.night.common.entity.card.CardInMachine;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName: CardInMachineController
 * @Description: CardInMachineController
 * @author: CHX42
 * @date: 2022/10/25-10:43
 * @version: v1.0
 */
@RestController
@RequestMapping("/api/cardInMachine")
public class CardInMachineController {
    @Resource
    private CardInMachineService cardInMachineService;

    @PostMapping("/add")
    public ResultVo<?> add(@RequestBody CardInMachine cardInMachine) {
        cardInMachineService.add(cardInMachine);
        return ResultVo.SUCCESS;
    }

    @PostMapping("/list")
    public ResultVo<?> list(@RequestBody CardDataVo<CardInMachine, CardInMachine> cardInMachineDataVo) {
        PageInfo<CardInMachine> machinePageInfo = cardInMachineService.getBy(cardInMachineDataVo.getPageInfo());
        return new ResultVo<>(machinePageInfo);
    }

    @PostMapping("/update")
    public ResultVo<?> update(@RequestBody CardInMachine cardInMachine) {
        cardInMachineService.update(cardInMachine);
        return ResultVo.SUCCESS;
    }
    @PostMapping("/getById")
    public ResultVo<?> getById(@RequestBody CardInMachine cardInMachine) {
        cardInMachineService.add(cardInMachine);
        return ResultVo.SUCCESS;
    }

}